import request from '@/utils/request';
import { AxiosPromise } from 'axios';
import { LegalCaseVo, LegalCaseForm, LegalCaseQuery } from '@/api/legalcase/types';

/**
 * 查询法律案例列表
 * @param query
 * @returns {*}
 */

export const listLegalCase = (query?: LegalCaseQuery): AxiosPromise<LegalCaseVo[]> => {
  return request({
    url: '/lawyer/legalCase/list',
    method: 'get',
    params: query
  });
};

/**
 * 查询法律案例详细
 * @param id
 */
export const getLegalCase = (id: string | number): AxiosPromise<LegalCaseVo> => {
  return request({
    url: '/lawyer/legalCase/' + id,
    method: 'get'
  });
};

/**
 * 新增法律案例
 * @param data
 */
export const addLegalCase = (data: LegalCaseForm) => {
  return request({
    url: '/lawyer/legalCase/saveLegalCase',
    method: 'post',
    data: data
  });
};

/**
 * 修改法律案例
 * @param data
 */
export const updateLegalCase = (data: LegalCaseForm) => {
  return request({
    url: '/lawyer/legalCase/updateLegalCase',
    method: 'post',
    data: data
  });
};

/**
 * 删除法律案例
 * @param id
 */
export const delLegalCase = (id: string | number | Array<string | number>) => {
  return request({
    url: '/lawyer/legalCase/removeLegalCase/' + id,
    method: 'delete'
  });
};
